#ifndef ESP8266_ESWIN_H
#define ESP8266_ESWIN_H

#include <stdint.h>
#include "uart_driver.h"
#include "../board/sdk_project_config.h"


#define CLOUD_PLANTFORM "bemfa.com"

// #define release

#ifdef release
#define WIFI_SSID "xxx"
#define WIFI_PASSWORD "xxx"
#define CLOUD_UID "xxx"
#else

#define WIFI_SSID "MEIZU 20 Pro"
#define WIFI_PASSWORD "20040219"
#define CLOUD_UID "60ce8437cee20782e7355a16e6bb6a39"
#endif

#define CLOUD_TOPIC_POST1 "Sensor"
#define CLOUD_TOPIC_POST2 "MPU6050"
#define CLOUD_TOPIC_POST3 "GPS"
#define CLOUD_TOPIC_POST4 "Count"
#define CLOUD_TOPIC_GET "GetControl"

#define CLOUD_PORT "8344"

// 超时和重试配置
#define AT_TIMEOUT_MS 5000 // AT指令响应超时
#define MAX_RETRIES 3      // 指令重试次数



// ESP8266 操作状态枚举
typedef enum {
    ESP_OK,        // 操作成功
    ESP_ERROR,     // 操作失败
    ESP_TIMEOUT    // 操作超时
} ESP_Status;

// 初始化函数
ESP_Status ESP8266_Init(void);

// Wi-Fi 连接函数
ESP_Status ESP_ConnectToWiFi(void);

// TCP 服务器连接函数
ESP_Status ESP_ConnectToTCPServer(void);

// 发送数据到云端
ESP_Status ESP_Send_Sensor_Data(float data1, float data2, float data3, uint16_t data4);
ESP_Status ESP_Send_GPS_Data(float Latitude, float Longitude);
ESP_Status ESP_Send_MPU6050_Data(float data1, float data2, float data3, float data4, float data5, float data6);
ESP_Status ESP_Send_Count_Data(uint32_t OPEN_Door,uint32_t CLOSE_Door, uint32_t OPEN_Light, uint32_t Shock);
// 发送原始字符串数据到云端
ESP_Status ESP_SendString(const uint8_t *data, uint16_t len);

// 发送心跳包到云端
ESP_Status ESP_SendPing(void);


void ESP_RxCallback(void *driverState, uart_event_t event, void *callbackParam);

#endif // ESP8266_ESWIN_H
